/**
 * 员工列表的相关接口
 */

import request from '@/utils/request'

// TAG 获取员工的综合列表
export const getEmployeeList = params => {
  return request({
    method: 'GET',
    url: '/sys/user',
    params
  })
}

// TAG 删除员工
export const delEmployee = id => {
  return request({
    method: 'DELETE',
    url: `/sys/user/${id}`
  })
}

// TAG 新增员工
export const addEmployee = data => {
  return request({
    method: 'POST',
    url: '/sys/user',
    data
  })
}

// TAG 导入员工
export function importEmployee (data) {
  return request({
    url: '/sys/user/batch',
    method: 'post',
    data
  })
}

// TAG 根据id获取某个用户的基本信息
export const getUserDetailById = id => {
  return request({
    method: 'GET',
    url: `/sys/user/${id}`
  })
}

// TAG 保存员工的基本信息
export const saveUserDetailById = data => {
  return request({
    method: 'PUT',
    url: `/sys/user/${data.id}`,
    data
  })
}

// TAG 读取用户详情的基础信息
export const getPersonalDetail = id => {
  return request({
    method: 'GET',
    url: `/employees/${id}/personalInfo`
  })
}

// TAG 保存员工个人信息 ( 更新用户详情的基础信息)
export const updatePersonal = data => {
  return request({
    method: 'PUT',
    url: `/employees/${data.userId}/personalInfo`,
    data
  })
}

// TAG 获取用户的岗位信息
export const getJobDetail = id => {
  return request({
    method: 'GET',
    url: `/employees/${id}/jobs`
  })
}

// TAG 保存岗位信息
export const updateJob = data => {
  return request({
    method: 'PUT',
    url: `/employees/${data.userId}/jobs`,
    data
  })
}

// 给用户分配角色
export const assiginRoles = data => {
  return request({
    method: 'PUT',
    url: '/sys/user/assignRoles',
    data
  })
}
